package com.hrzyit.whistle.user.presenter

import com.hrzyit.base.ext.execute
import com.hrzyit.base.presenter.BasePresenter
import com.hrzyit.base.rx.BaseObserver
import com.hrzyit.whistle.user.presenter.view.ForgetPwdView
import com.hrzyit.whistle.user.service.IUserService
import javax.inject.Inject

/**
 * Presenter: 忘记密码
 * @author YangWei
 * @date 2019/3/21
 */
class ForgetPwdPresenter @Inject constructor():BasePresenter<ForgetPwdView>() {

    @Inject
    lateinit var userService: IUserService

    /**
     * 忘记密码
     */
    fun forgetPwd(mobile: String, verifyCode: String) {

        // 检查网络
        if (checkNetWork().not()){
            return
        }

        mView.showLoading()

        userService.forgetPwd(mobile,verifyCode).execute(object: BaseObserver<Boolean>(mView){

            override fun onNext(t: Boolean) {
                if (t) {
                    mView.onForgetPwdResult("验证成功")
                }
            }
        },lifecycleProvider)

    }

}